<?php
/**
 * 简单工厂模式
 */

class Cat
{
    public function __construct()
    {
        echo "一只猫";
    }
}

class Dog
{
    public function __construct()
    {
        echo "一只狗";
    }
}

class SimpleFactory
{
    public static function build(string $type)
    {
        switch($type)
        {
            case "cat":
                return new Cat();
            case "dog":
                return new Dog();
            default:
                return false;
        }
    }
}

SimpleFactory::build("cat");
SimpleFactory::build("dog");

